package com.anda.logistics.service.impl;

import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;

import org.hibernate.HibernateException;
import org.springframework.stereotype.Component;

import com.anda.logistics.dao.AndaBaseDao;
import com.anda.logistics.service.AndaBaseService;
import com.anda.logistics.util.JQGridJsonData;
import com.anda.logistics.util.JQGridPager;
@Component
public class AndaBaseServiceImpl implements AndaBaseService {
	private AndaBaseDao andaBaseDao;
	@Override
	public void save(Object entity) {
		andaBaseDao.save(entity);
	}

	@Override
	public void update(Object entity) {
		andaBaseDao.save(entity);
	}

	public AndaBaseDao getAndaBaseDao() {
		return andaBaseDao;
	}
	@Resource
	public void setAndaBaseDao(AndaBaseDao andaBaseDao) {
		this.andaBaseDao = andaBaseDao;
	}

	@Override
	public void deleteAll(Class c, String[] ids) {
		for(String sid : ids){
			Object o = andaBaseDao.get(c, Integer.parseInt(sid));
			andaBaseDao.delete(o);
		}
		
	}

//	@Override
//	public JQGridJsonData getJQGridJsonData(JQGridPager pager, String tableName,
//			String idName, String [] columns){
//		return andaBaseDao.getJQGridJsonData(pager, tableName, idName, columns);
//	}
	
	@Override
	public JQGridJsonData getJQGridJsonData(JQGridPager pager, 
			String idName, String [] columns, Class clazz) throws NoSuchFieldException, SecurityException, HibernateException, ParseException{
		return andaBaseDao.getJQGridJsonData(pager, idName, columns, clazz);
	}
	

}
